package ch.bfh.abcm.rems.sensors.tinkerforge;

import ch.bfh.abcm.rems.exceptions.UnknownDeviceTypeException;

public enum TFSensorType {

        AMBIENT(21,"Lux",1, "Beleuchtungsstärke"),
        BAROMETER(221, "mbar",1, "Luftdruck"),
        COLOR(243, "RGB",1, "Farbwert"),
        DISTANCE_IR(25, "mm",1, "Distanz Infrarot"),
        DISTANCE_US(229, "cm",1, "Distanz Schall"),
        HALL_EFFECT(240, "Gauss",1, "Magnetfeld"),
        HUMIDITY(27, "%",1, "Luftfeuchtigkeit"),
        LINE(241, "nm",1, "Line"),
        MOISTURE(232, "mA",1, "Absolute Feuchtigkeit"),
        MOTION_DETECTOR(233, "1/0",0, "Bewegungsmeldung"),
        SOUND_INTENSITY(238, "Hüllkurve",1,"Lautstärke"),
        TEMPERATURE(216, "°C", 2, "Temperatur"), 
        TEMPERATURE_IR(217, "°C", 1, "Temperatur Infrarot"),
        TILT(239, "1/0",1, "Lage");
        
    private final String unit;
    private final String idendifier;
    private final int deviceIdentifier;
    private final int decimalDigits;

    private TFSensorType(int deviceIdentifier, String unit, int decimalDigits, String idendifier) {
        this.deviceIdentifier = deviceIdentifier;
        this.idendifier = idendifier;
        this.unit = unit;
        this.decimalDigits = decimalDigits;
    }

    public int getDeviceIdentifier() {
        return deviceIdentifier;
    }

    public String getUnit() {
        return unit;
    }

    public int getDecimalDigits() {
        return decimalDigits;
    }

    public String getIdendifier() {
        return idendifier;
    }

    public static TFSensorType getByDeviceIdentifier(int deviceIdentifier) {
        for (TFSensorType type : values()) {
            if (type.getDeviceIdentifier() == deviceIdentifier) {
                return type;
            }
        }
        throw new UnknownDeviceTypeException("TFType with Idendifier " + deviceIdentifier + " not implemented");
    }
    
    
}
